<?

if ( !defined( 'MEDIAWIKI' )) die();

$wgExtensionCredits['other'][] = array(
	'path' => __FILE__,
	'name' => 'AnonimSpace', 
	'author' => array( 'Gluon Graviton'), 
	'url' => 'http://mediawiki.org/wiki/Extension:AnonimSpace',
	'descriptionmsg' => 'AnonimSpace-desc',
);

$wgExtensionMessagesFiles['AnonimSpace'] = dirname(__FILE__) . '/AnonimSpace.i18n.php';

$wgHooks['userCan'][] = 'fExtensionAnonimSpaceuserCan';

function fExtensionAnonimSpaceuserCan(&$title, &$user, $action, &$result){
	if(!$user->isAnon()){
        return true;
    }
	global $wgGroupPermissions,$AnonimSpaceList;
	$wgGroupPermissions['*']['createaccount'] = false;
	$wgGroupPermissions['*']['edit'] = false;
	$wgGroupPermissions['*']['createpage'] = false;
	$wgGroupPermissions['*']['createtalk'] = false;
	$wgGroupPermissions['*']['writeapi'] = false;
	$NameSpaceNumber = $title->getNamespace();
	if (isset($AnonimSpaceList)){
		if(array_key_exists($NameSpaceNumber, $AnonimSpaceList)){
			foreach ($AnonimSpaceList[$NameSpaceNumber] as $AnonimSpace => $act){
				$wgGroupPermissions['*'][$act] = true;
			}
		}
	}
	return true;
}